﻿using System;
using System.ComponentModel;
using SIMA.Core.Data.Entity;

namespace SIMA.Core.Data.Access
{
    public abstract class AccessClass<T>:IDisposable,INotifyPropertyChanged where T:XmlEntity
    {
        #region Consts

        public const string CADCONNECTIONSTRING = "Data Source=.;Initial Catalog=SIMA;Integrated Security=True";

        #endregion

        #region Constructor

        public AccessClass()
        {
        }

        #endregion

        #region Methods

        public abstract void Register(T item);

        public abstract void Delete(T item);

        public abstract void Update(T itemToUpdate, T itemUpdated);

        public abstract void SelectAll();


        #endregion

        #region Destructor

        ~AccessClass()
        {
            this.Dispose();
        }

        #endregion

        #region Miembros de IDisposable

        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        #endregion

        #region Miembros de INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisePropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this,new PropertyChangedEventArgs(property));
            }
        }

        #endregion
    }
}
